package com.bwie.controller;

import com.bwie.service.TbOrderService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.TbProdVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description :
 * @Author QiHainan
 * @Create 2025/3/22 8:06
 * @Version 1.0
 */
@RestController
@RequestMapping("/order/index")
public class IndexController {
    @Autowired
    private TbOrderService tbOrderService;

    @PostMapping("/getOrderById/{orderId}")
    public R getOrderById(@PathVariable(name = "orderId") int orderId){
        return tbOrderService.getOrderById(orderId);
    }

    /**
     * 获取订单分页
     */
    @PostMapping("/getOrderList")
    public R getOrderList(@RequestBody PageInfoVo pageInfoVo){
        return tbOrderService.getOrderList(pageInfoVo);
    }

    /**
     * 下单
     * @param prodVoList
     * @return
     */
    @PostMapping("/addOrder")
    public R addOrder(@RequestBody List<TbProdVo> prodVoList){
        return tbOrderService.addOrder(prodVoList);
    }

    /**
     * 最近7天的销售额，以柱形图的形式展示每天的交易金额
     * @return
     */
    @PostMapping("/getOrderAmountFormWeek")
    public R getOrderAmountFormWeek(){
        return tbOrderService.getOrderAmountFormWeek();
    }
}
